#include<iostream>
#include<cstring>
#include<bitset>
#include<queue>
using namespace std;
const int N = 3e4 + 10;
int h[N], e[N], ne[N], idx;
int d[N];
int n, m;
int seq[N];
bitset<N>f[N];
void add(int a, int b)
{
	e[idx] = b;
	ne[idx] = h[a];
	h[a] = idx++;
}
void topsort()
{
	queue<int>q;
	for (int i = 1; i <= n; i++) {
		if (!d[i]) {
			q.push(i);
		}
	}
	int k = 0;
	while (q.size()) {
		int t = q.front();
		q.pop();
		seq[k++] = t;
		for (int i = h[t]; ~i; i = ne[i]) {
			int j = e[i];
			if (--d[j] == 0) {
				q.push(j);
			}
		}
	}
}
int main()
{
	cin >> n >> m;
	memset(h, -1, sizeof(h));
	while (m--) {
		int a, b;
		cin >> a >> b;
		add(a, b);
		d[b]++;
	}
	topsort();
	for (int i = n - 1; i >= 0; i--) {
		int a = seq[i];
		f[a][a] = 1;
		for (int j = h[a]; ~j; j = ne[j]) {
			f[a] |= f[e[j]];
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << f[i].count() << endl;
	}
	return 0;
}